import {
	createStore
} from 'vuex'

const store = createStore({
	state: {
		userinfo: uni.getStorageSync('userinfo') || {}, //用户信息
		//单聊聊天用户信息
		chatUser: {
			"id": 4,
			"leaderid": "9",
			"title": "群1",
			"img": "",
			"announcement": "",
			"createTime": "2023-03-23T15:43:23.000Z",
			"userid": 9,
			"addtime": "2023-03-24T04:55:00.000Z",
			"unread": null,
			"is_shield": 0,
			"crowd_id": 1
		},
		chatID: '',
		users: [], //用户信息
		$socket: null, //存储$socket对象
		chatRecords: [] //未读聊天信息
	},
	mutations: {
		chatUser(state, data) {
			state.chatUser = data
		},
		chatID(state, data) {
			state.chatID = data
		},
		users(state, data) {
			state.users = data
		},
		$socket(state, data) {
			state.$socket = data
		},
		chatRecords(state, data) {
			state.chatRecords = data
		}
	},
	actions: {
		chatRecords({
			commit
		}, chatRecords) {
			commit('chatRecords', chatRecords)
		}
	},
	getters: {
		users(state) {
			return state.users
		}
	},
	modules: {

	}
})

export default store